<!doctype html>
<html class="no-js fixed-layout">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>文章管理</title>
    <meta name="description" content="这是一个 index 页面">
    <meta name="keywords" content="index">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="icon" type="image/png" href="__Cssjs__/assets/i/favicon.png">
    <link rel="apple-touch-icon-precomposed" href="__Cssjs__/assets/i/app-icon72x72@2x.png">
    <meta name="apple-mobile-web-app-title" content="Amaze UI" />
    <link rel="stylesheet" href="__Cssjs__/assets/css/amazeui.min.css"/>
    <link rel="stylesheet" href="__Cssjs__/assets/css/admin.css">
</head>
<body>
<!--[if lte IE 9]>
<p class="browsehappy">你正在使用<strong>过时</strong>的浏览器，Amaze UI 暂不支持。 请 <a href="http://browsehappy.com/" target="_blank">升级浏览器</a>
    以获得更好的体验！</p>
<![endif]-->

<header class="am-topbar am-topbar-inverse admin-header">
{include file="public/head"}
</header>

<div class="am-cf admin-main">
    <!-- sidebar start -->
    {include file="public/sidebar"}
    <!-- sidebar end -->

    <!-- content start -->
    <div class="admin-content">
        <div class="admin-content-body">
            <div class="am-cf am-padding am-padding-bottom-0">
                <div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">文章管理</strong></div>
            </div>

            <hr>

            <div class="am-g">
                <div class="am-u-sm-12 am-u-md-6">
                    <div class="am-btn-toolbar">
                        <div class="am-btn-group am-btn-group-xs">
                            <button type="button" class="am-btn am-btn-default" onclick="javascript:window.location.href='/admin/post'"><span class="am-icon-plus"></span> 新增</button>
                            <button type="button" class="am-btn am-btn-default"><span class="am-icon-trash-o"></span> 删除</button>
                        </div>
                    </div>
                </div>
                <div class="am-u-sm-12 am-u-md-3">
                    <div class="am-form-group">
                        <select data-am-selected="{btnSize: 'sm'}">
                            <option value="option1">所有类别</option>
                            <option value="option2">IT业界</option>
                            <option value="option3">数码产品</option>
                            <option value="option3">笔记本电脑</option>
                            <option value="option3">平板电脑</option>
                            <option value="option3">只能手机</option>
                            <option value="option3">超极本</option>
                        </select>
                    </div>
                </div>
                <div class="am-u-sm-12 am-u-md-3">
                    <div class="am-input-group am-input-group-sm">
                        <input type="text" class="am-form-field">
                        <span class="am-input-group-btn">
            <button class="am-btn am-btn-default" type="button">搜索</button>
          </span>
                    </div>
                </div>
            </div>
            <div class="am-g">
                <div class="am-u-sm-12">
                    <form class="am-form">
                        <table class="am-table am-table-striped am-table-hover table-main">
                            <thead>
                            <tr>
                                <th class="table-check"><input type="checkbox" /></th>
                                <th class="table-id">ID</th>
                                <th class="table-title">标题</th>
                                <th class="table-type">栏目</th>
                                <th class="table-type">标签</th>
                                <th class="table-type">阅读量</th>
                                <th class="table-author am-hide-sm-only">作者</th>
                                <th class="table-date am-hide-sm-only">发表日期</th>
                                <th class="table-set">操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            {volist name='article_list' id='vo'}
                            <tr>
                                <td><input type="checkbox" /></td>
                                <td>{$vo.id}</td>
                                <td><a href="/home/read?id={$vo.id}" target="_blank">{$vo.title}</a></td>
                                <td>{$vo.name}</td>
                                <td>{$vo.tag}</td>
                                <td>{$vo.pv}</td>
                                <td class="am-hide-sm-only">{$vo.username}</td>
                                <td class="am-hide-sm-only">{$vo.publictime}</td>
                                <td>
                                    <div class="am-btn-toolbar">
                                        <div class="am-btn-group am-btn-group-xs">
                                            <!--
                                            <a class="am-btn am-btn-default" href="/blog/index.php/admin/article/edit?id={$vo.id}"><i class="am-icon-pencil-square-o"></i>编辑</a>
                                            <a class="am-btn am-btn-default" href="/blog/index.php/admin/article/delete?id={$vo.id}"><i class="am-icon-trash-o"></i>删除</a>
                                            -->
                                            <button type="button" class="am-btn am-btn-default am-btn-xs am-text-secondary"  onclick="javascript:window.location.href='/blog/index.php/admin/article/edit?id={$vo.id}'"><span class="am-icon-pencil-square-o"></span> 编辑</button>
                                            <button type="button" class="am-btn am-btn-default am-btn-xs am-text-danger am-hide-sm-only" onclick="javascript:window.location.href='/blog/index.php/admin/article/delete?id={$vo.id}'"><span class="am-icon-trash-o"></span> 删除</button>
                                        </div>
                                    </div>
                                </td>
                            </tr>
                            {/volist}
                            </tbody>
                        </table>
                        <hr/>
                        <div class="am-cf">
                            <div class="am-fr">
                                <ul class="am-pagination">
                                    <li class="am-disabled"><a href="#">«</a></li>
                                    <li class="am-active"><a href="#">1</a></li>
                                    <li><a href="#">2</a></li>
                                    <li><a href="#">3</a></li>
                                    <li><a href="#">4</a></li>
                                    <li><a href="#">5</a></li>
                                    <li><a href="#">»</a></li>
                                </ul>
                            </div>
                        </div>
                    </form>
                </div>

            </div>
        </div>
    </div>
    <!-- content end -->

</div>

<a href="#" class="am-icon-btn am-icon-th-list am-show-sm-only admin-menu" data-am-offcanvas="{target: '#admin-offcanvas'}"></a>

<!--[if lt IE 9]>
<script src="http://libs.baidu.com/jquery/1.11.1/jquery.min.js"></script>
<script src="http://cdn.staticfile.org/modernizr/2.8.3/modernizr.js"></script>
<script src="__Cssjs__/assets/js/amazeui.ie8polyfill.min.js"></script>
<![endif]-->

<!--[if (gte IE 9)|!(IE)]><!-->
<script src="__Cssjs__/assets/js/jquery.min.js"></script>
<!--<![endif]-->
<script src="__Cssjs__/assets/js/amazeui.min.js"></script>
<script src="__Cssjs__/assets/js/amazeui.dialog.min.js"></script>
<script src="__Cssjs__/assets/js/app.js"></script>
<script src="__Cssjs__/vendor/wangEditor/dist/js/wangEditor.min.js"></script>
<link rel="stylesheet" href="__Cssjs__/vendor/wangEditor/dist/css/wangEditor.min.css">
<script type="text/javascript">
    var editor = new wangEditor('wangEdit');
    editor.create();
</script>
<script type="text/javascript">
    var category_m_id='';
    var category_b_id=''
    $("#cate_m").on('change',function () {
        category_m_id=$(this).val();
        $("#cate_b").empty();
        $.post("/admin/post/cate_b",{"pid":$(this).val()},function (data) {
            if (data==0){
                $("#cate_b").display('none');
            }
            $("#cate_b").append("<option selected value=''></option>")
            $.each(data,function () {
                $("#cate_b").append("'<option value='"+this.id+"'>"+this.name+"</option>'");
            })

        },"json")
    });
    $("#cate_b").on('change',function () {
        category_b_id=$(this).val();
    });
    function post() {
        alert("category_m_id"+category_m_id+"category_b_id"+category_b_id);
        var content=editor.$txt.html();
        var title=$("#title").val();
        var tag=$("#tag").val();
        var intro=editor.$txt.text();
        $.ajax({
            url:"/admin/post/post",
            type:"post",
            data:{"title":title,"content":content,"tag":tag,"intro":intro,"category_m_id":category_m_id,"category_b_id":category_b_id},
            dataType:"json",
            success:function (data) {
                if (data=='success'){
                    //$("#success_alert").modal(); 弹出层使用
                    AMUI.dialog.alert({
                        content:'发表成功！',
                        onConfirm: function() {
                            console.log('close');
                        }
                    });

                }
            },
            error:function (jqXHR) {
                alert("AJAX错误，返回状态："+jqXHR.status);
            }
        })
    }
    function article_edit() {
       alert();
       window.location.href='/home/index';
    }
    function article_del() {

    }
</script>
</body>
</html>